﻿/// <summary>
/// data   :2016-05-25
/// author :fanzhengyong
/// 文件读取帮助类
/// </summary>
using System;
using UnityEngine;
using System.Collections;
using System.IO;

namespace UEngine
{
    public class FileHelper
    {
        public static bool GetTextFromAB(string path, string assetName, ref TextAsset textAsset)
        {
            //bool retCode    = false;
            bool result     = false;
            

            return result;

        }

        public static bool CreateAssetbundleFile(string path, byte[] data)
        {

            bool result = false;
            Stream stream = null;
            try
            {
                FileInfo fileInfo = new FileInfo(path);
                using (stream = fileInfo.Open(FileMode.Create))
                {
                    stream.Write(data, 0, data.Length);
                }
                result = true;
            }
            catch (Exception e)
            {
                Debug.Log(e.ToString());
            }

            return result;
        }

        public static byte[] ReadFromFile(string path)
        {
            if (File.Exists(path))
            {
                return (File.ReadAllBytes(path));
            }
            return null;
        }
    }
    
}

